﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Desktop.Dialogs
{
    /// <summary>
    /// Interaction logic for BloggerImport.xaml
    /// </summary>
    public partial class BloggerImport : Window
    {
        #region Constructors

        private BloggerImport()
        {
            InitializeComponent();
            Background = SystemColors.ControlBrush;
        }

        #endregion

        #region Properties

        public string FeedUrl
        {
            get
            {
                return feedUrlTextBox.Text;
            }
        }

        #endregion

        #region Methods

        public static string GetFeedUrl()
        {
            BloggerImport dlg = new BloggerImport();
            if (!dlg.ShowDialog().GetValueOrDefault(false))
            {
                return string.Empty;
            }
            string feedUrl = dlg.FeedUrl;
            if (feedUrl.EndsWith("/"))
            {
                return dlg.FeedUrl + "feeds/posts/default";
            }
            else if (feedUrl.EndsWith("/feeds/posts/default"))
            {
                return feedUrl;
            }
            else
            {
                return feedUrl + "/feeds/posts/default";
            }
        }

        #endregion

        #region Event Handlers

        private void acceptButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            Close();
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }

        #endregion
    }
}